home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2003 June / macformat-130.iso / mac / Reviewed⁄Demos / Spearhead Demo / demota / pak1.pk3 / global / breathe.scr < prev    next >
Encoding:
Text File  |  2002-10-21  |  3.3 KB  |  115 lines

  1. ///////////////////////////////////////////////////////////////////////////////////////////
  2. // Breathe.scr
  3. //
  4. // Makes a guy breathe steam and occasionally mumble, whistle, or make other small noises.  
  5. // Whether or not he breathes steam is controlled through the first parameter, and also 
  6. // through the character's variable self.breathsteam.  Whether or not he mumbles is 
  7. // controlled by the second parameter and also through self.mumble.
  8. // The character's breathing can be externally controlled by calls to the function 
  9. // setbreatheout local.aftertime, which takes the amount of time until the next breathe
  10. // out.  Thus a call of setbreatheout 0 would cause him to breathe out immediately.
  11. //
  12. ///////////////////////////////////////////////////////////////////////////////////////////
  13.  
  14. start local.breathsteam local.mumble:
  15.  
  16.     self waittill spawn    // Makes sure that the level is initialised correctly for guys that are
  17.                         // built into the level.
  18.     if !(isalive self)
  19.     {
  20.         end
  21.     }
  22.  
  23.     self.mumble = int local.mumble
  24.     self.breathsteam = int local.breathsteam
  25.     self.breathetimebase = 8
  26.     self.breathetimerand = 4
  27.     self.breathstillmumble = (randomint 3) + 2
  28.  
  29.     thread breatheout ( (randomint self.breathetimerand) + self.breathetimebase )
  30.     self.breathethread = parm.previousthread
  31.  
  32. end
  33.  
  34. /////////////////////////////////////////////////
  35. //
  36. // setbreathsteam - turns steam breathing on or off
  37. //
  38. /////////////////////////////////////////////////
  39. setbreathsteam local.breathsteam:
  40.     self.breathsteam = int local.breathsteam
  41. end
  42.  
  43. /////////////////////////////////////////////////
  44. //
  45. // setmumble - turns mumbling on or off
  46. //
  47. /////////////////////////////////////////////////
  48. setmumble local.mumble:
  49.     self.mumble = int local.mumble
  50. end
  51.  
  52. /////////////////////////////////////////////////
  53. //
  54. // breatheout - waits aftertime seconds and then
  55. // breathes out.  If it's time to mumble, also
  56. // calls the mumble function.
  57. //
  58. /////////////////////////////////////////////////
  59. breatheout local.aftertime:
  60.  
  61.     wait local.aftertime
  62.  
  63.     if !(isalive self)
  64.     {
  65.         end
  66.     }
  67.     if (self.breathsteam == 1)
  68.     {
  69.         // Attach the emmitter and tell it to remove when the guy dies
  70.         self    attachmodel models/emitters/breath_steam_emitter.tik "Bip01 Head" 1 1
  71.     }
  72.  
  73.     if ( (self.mumble == 1) && (self.mood == "bored") && (self.silent != 1) )
  74.     {
  75.         self.breathstillmumble -= 1
  76.         if ( self.breathstillmumble <= 0 )
  77.         {
  78.             waitthread mumble
  79.             if !(isalive self)
  80.             {
  81.                 end
  82.             }
  83.             self.breathstillmumble = (randomint 3) + 3
  84.         }
  85.     }
  86.  
  87.     thread breatheout ( (randomint self.breathetimerand) + self.breathetimebase )
  88.     self.breathethread = parm.previousthread
  89. end
  90.  
  91. /////////////////////////////////////////////////
  92. //
  93. // nextbreathtime - resets the amount of time 
  94. // until the next breathe out.
  95. //
  96. /////////////////////////////////////////////////
  97. nextbreathtime local.aftertime:
  98.     self.breathethread end
  99.     thread breatheout local.aftertime
  100.     self.breathethread = parm.previousthread
  101. end
  102.  
  103. /////////////////////////////////////////////////
  104. //
  105. // mumble - mumbles, whistles, hums, coughs etc
  106. //
  107. /////////////////////////////////////////////////
  108. mumble:
  109.     if (self.team == "german")    // Only Germans have mumble lines
  110.     {
  111.     ////self say ("snd_den_grunt_generic_" + self.voicetype)
  112.         self playsound ("snd_den_grunt_generic_" + self.voicetype)
  113.     }
  114.     wait 2
  115. end